package SI::Record::NewInsuring;

use base qw/MyDB::Object/;

__PACKAGE__->meta->setup(
table => 'InsurRec',
columns => [
    base_sn => {type=>'varchar', length=>16, not_null=>1},
    insur_reason_code => {type=>'datetime', not_null=>1},
    insur_time => {type=>'datetime',not_null=>1},
    insur_type => {type=>'varchar', length=>40, not_null=>1},
    regist_time => {type=>'datetime',not_null=>1},
    register => {type=>'varchar',length=>60,not_null=>1},
],
allow_inline_column_values => 1,
primary_key_columns => [ 'base_sn', 'insur_time' ],

);



sub init_tab {
  my $self = shift;
  my $stmt = 'CREATE TABLE IF NOT EXISTS InsurRec (
  base_sn VARCHAR(16) NOT NULL,        /* 人员序列号 */
  insur_reason_code VARCHAR(3) NOT NULL, -- 参保原因代码
  insur_time DATE NOT NULL, -- 参保时间
  insur_type VARCHAR(40) NOT NULL,  -- 险种
  regist_time DATETIME NOT NULL,  -- 登记时间
  register VARCHAR(60) NOT NULL  -- 登记人
  );';

  my $db = $self->init_db;
  my $dbh = $db->dbh or die $db->error;
    $db->do_transaction(sub {$dbh->do($stmt)})
        or die $db->error;
    return 1;
}


1;
